﻿// <copyright file="DirectorPropertyEditor.cs" company="City of Portland, BES-ASM">
// </copyright>
// <summary>DirectorPropertyEditor Form</summary>

namespace BESASM.EMGAATS.UI
{
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using BESASM.EMGAATS.BusinessClasses;

  /// <summary>
  /// A form for editing director properties.
  /// </summary>
  public partial class DirectorPropertyEditor : Form
  {
    /// <summary>
    /// Initializes a new instance of the <see cref="DirectorPropertyEditor"/> class.
    /// </summary>
    public DirectorPropertyEditor()
    {
      this.InitializeComponent();

      foreach (var directorType in Enum.GetValues(typeof(DirectorType)))
      {
        this.directorTypeComboBox.Items.Add(directorType);
      }
    }

    /// <summary>
    /// Gets or sets the director to be edited.
    /// </summary>
    public IDirector Director
    {
      get
      {
        return this.directorBindingSource.DataSource as IDirector;
      }

      set
      {
        this.directorBindingSource.DataSource = null;

        this.toNodeTextBox.Text = "<Null>";

        if (value != null)
        {
          if (value.ToNode != null)
          {
            this.toNodeTextBox.Text = value.ToNode.NodeName;
          }
        }

        this.directorBindingSource.DataSource = value;
      }
    }

    private void CancelButton_Click(object sender, EventArgs e)
    {
      this.Close();
    }
  }
}
